class RandomizedSet {
  record: number[]
  mapper: Map<number, number>
  curr: number
  constructor() {
      this.record = [];
      this.mapper = new Map();
      this.curr = 0;
  }

  insert(val: number): boolean {
      if(this.mapper.has(val)){
          return false;
      } else {
          this.mapper.set(val, this.record.length);
          this.record.push(val);
          return true;
      }
  }

  remove(val: number): boolean {
      let i = this.mapper.get(val);
      if(i === undefined) {
          return false;
      } else {
          this.record[i] = this.record[this.record.length - 1];
          this.mapper.set(this.record[this.record.length - 1], i);
          this.record.pop()
          this.mapper.delete(val);
          return true;
      }
  }

  getRandom(): number {
      return this.record[Math.floor(Math.random() * this.record.length)]
  }
}

/**
* Your RandomizedSet object will be instantiated and called as such:
* var obj = new RandomizedSet()
* var param_1 = obj.insert(val)
* var param_2 = obj.remove(val)
* var param_3 = obj.getRandom()
*/